package com.xungou.goodTypePropertyValue.controller;

import com.xungou.goodTypePropertyValue.pojo.GoodTypePropertyValue;
import com.xungou.goodTypePropertyValue.service.IGoodTypePropertyValueService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/goodTypePropertyValue")
public class GoodTypePropertyValueController {
    @Resource
    private IGoodTypePropertyValueService goodTypePropertyValueService;

    @RequestMapping("/add")
    @ResponseBody
    public Map<String, Object> add(GoodTypePropertyValue goodTypePropertyValue){
        int flag = goodTypePropertyValueService.insert(goodTypePropertyValue);
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("flag",flag);
        result.put("id",goodTypePropertyValue.getId());
        return result;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Map<String, Object> delete(Integer id) {
        int flag = goodTypePropertyValueService.deleteByPrimaryKey(id);
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("flag",flag);
        return result;
    }

    @RequestMapping("/search")
    @ResponseBody
    public List<Map<String, Object>> search(@RequestParam Map<String, String> params) {
        List<Map<String, Object>> result = goodTypePropertyValueService.search(params);
        return result;
    }
}